//package example.demo.mideng;
//
//import lombok.extern.slf4j.Slf4j;
//import org.springframework.aop.framework.*;
//import org.springframework.aop.support.AopUtils;
//import org.springframework.beans.BeansException;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.data.redis.core.StringRedisTemplate;
//import org.springframework.stereotype.Component;
//
///**
// * 借鉴com.alibaba.druid.support.spring.stat.annotation.StatAnnotationBeanPostProcessor
// */
//@Slf4j
////@Component
//public class MiDengBeanPostProcessor extends AbstractAdvisingBeanPostProcessor {
//    @Autowired
//    private StringRedisTemplate stringRedisTemplate;
//
//    /**
//     * BeanPostProcessor这里是责任链模式。所以MiDengBeanPostProcessor在AbstractAdvisingBeanPostProcessor类后面就行
//     * 不进行而外的处理，直接return bean就ok了
//     */
//    public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
//        //先拿到父类的aop生成的代理对象
////        bean = super.postProcessAfterInitialization(bean, beanName);
//        if (AopUtils.isAopProxy(bean)) {
//            //目标对象
////            Object singletonTarget = AopProxyUtils.getSingletonTarget(bean);
//            if (bean instanceof Advised) {
//                Advised advised = (Advised) bean;
//                MiDengAnnoAdvisor advisor = new MiDengAnnoAdvisor(new MiDengBeforeInterceptor(stringRedisTemplate));
//                //继续给这个代理对象，添加代理逻辑
//                advised.addAdvisor(advisor);
//                this.advisor = advisor;
//                return bean;
//            }
//        }
//        return bean;
//    }
//}
